/*
 * @Author: wuqingchun
 * @Date: 2024-09-23 19:55:50
 * @Description: 
 * @LastEditors: wuqingchun
 * @LastEditTime: 2024-09-29 17:19:50
 */
#ifndef __CHAT_NET_H__
#define __CHAT_NET_H__


#include "../deps/muduo/muduo/net/TcpServer.h"
#include "../deps/muduo/muduo/net/EventLoop.h"
#include "../deps/muduo/muduo/net/InetAddress.h"

#include "chat_config.h"

using namespace muduo;
using namespace muduo::net;

class CChatNet : public muduo::noncopyable
{
public:
    CChatNet();
    ~CChatNet();

    int32_t Start();
    void SetConnectCallback(const ConnectionCallback& refConnCB);
    void setMessageCallback(const MessageCallback& refMsgCB);
private:
    void __OnThreadInit(EventLoop* pobjEVLoop);
    
private:
    const CHAT_COMMON_CONFIG_S& m_refConfig;
    InetAddress m_objNetAddr;
    EventLoop   m_objEVLoop;
    std::string m_strServerName;
    TcpServer   m_objTcpServer;
};

#endif //__CHAT_NET_H__